package ipad.asia.service.consumer;

import ipad.asia.entity.Consumer;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;

@Component
@FeignClient(value = "provider-consumer")
public interface ConsumerFeign {
    /**
     * 登录说明：
     * 3是表示封号，禁止登录，跳转到申请解锁页面
     * 2表示严重警告！需要处理被举报的东西
     * 1表示举报，警告你不要再犯错误
     * 4表示可以正常登录
     * 0表示账号密码错误
     * @param user
     * @param password
     * @return
     * @throws IOException
     */
    @RequestMapping("/consumer/login")
     int login(@RequestParam(value = "user",required = false) String user,
                         @RequestParam(value = "password", required = false) String password);

    /**
     * 注册
     * @param user
     * @param password
     * @return
     */
    @RequestMapping ("/consumer/register")
     boolean register(@RequestParam(value = "user",required = false) String user,
                            @RequestParam(value = "password", required = false) String password,
                            @RequestParam(value = "email",required = false) String email,
                            @RequestParam(value = "phone",required = false) String phone
    );

    /**
     * 查找id，用作session
     * @param id
     * @return
     */
    @RequestMapping("/consumer/get")
     Consumer getId(@RequestParam(value = "id",required = false) int id);

    /**
     * 查找name，用作session
     * @return
     */
    @RequestMapping("/consumer/getName")
    Consumer getName(@RequestParam(value = "user",required = false) String user) ;

    /**
     * 更新个人信息
     * @param user
     * @param phone
     * @param email
     * @param sex
     * @param address
     * @param signature
     */
    @RequestMapping(value = "/consumer/updateInfo")
     void updateInfo( @RequestParam(value = "user",required = false)String user,
                            @RequestParam(value = "phone",required = false) String phone,
                            @RequestParam(value = "email",required = false) String email,
                            @RequestParam(value = "sex",required = false) String sex,
                            @RequestParam(value = "address",required = false) String address,
                            @RequestParam(value = "signature",required = false) String signature);

    @RequestMapping("/consumer/findAll")
     List<Consumer> findAll();
}